﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITAP.ContourBuilder.Components.Constraints
{
    [Serializable]
    public class ConstraintRemoveInvalidConnectors : Constraint
    {
        public override bool Check(IContourComponent component)
        {
            return false;
        }

        public override void Fix(IContourComponent component)
        {
            if (!enabled)
                return;

            int counter = 0;
            List<IContourComponent> connectorsToRemove = new List<IContourComponent>();
            foreach (IContourComponent connectedComponent in component.ConnectedComponents)
            {
                if (connectedComponent is ContourElement)
                    counter++;
            }

            if (counter != 2)
                component.Parent.RemoveInnerComponent(component);

            //foreach (IContourComponent connector in connectorsToRemove)
            //{
            //    ContourConnectionProvider.Disconnect(component, connector);
            //    connector.Parent.RemoveInnerComponent(connector);
            //}
        }
    }
}
